import store from "../store/index";
export default function init() {
  return new Promise((res, rej) => {
    let token = uni.getStorageSync("token");
    let tokenExpired = uni.getStorageSync("tokenExpired");
    if (token) {
      let now = Date.now();
      if (now >= tokenExpired) {
        //  过期了清除所有的本地储存
        localStorage.clear();
        res();
      } else {
        store.dispatch("get_userInfo", token).then(() => {
          res();
        });
      }
    } else {
      res();
    }
  });
}
